/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package lineage;

import lineage.bean.L1IdFactoryPc;
import lineage.config.L1Config;
import lineage.core.L1GameServer;
import lineage.database.tables.AccountTable;
import lineage.database.tables.CharactersTable;
import lineage.database.tables.ExpTable;
import lineage.database.tables.MapsTable;
import lineage.model.gameworld.L1World;
import lineage.model.map.L1WorldMap;
import lineage.ui.customize.L1Font;
import lineage.ui.function.window.main.L1Window;
import lineage.ui.util.L1LoadImage;
import lineage.util.Util;

/**
 * 用于在服务器启动时加载必须设置.
 * 
 * @version 2014年3月13日下午4:17:02
 * @author jrwz
 */
public final class Load {
    public Load() {
        init(); // 初始化
    }

    /**
     * 各项初始化.
     */
    private void init() {
        initUI(); // 初始化图形界面
        L1Config.init(); // 初始化服务器相关设置(属性文件)

        StringBuilder sb = new StringBuilder();
        sb.append("\r\n--------------------------------------------");
        Util.message(Util.SYSTEM_MESSAGE, sb.toString());

        MapsTable.getInstance(); // 地图
        L1WorldMap.getInstance(); // 加载txt格式地图文件
        AccountTable.getInstance(); // 账号
        ExpTable.getInstance(); // 经验值
        CharactersTable.getInstance(); // 角色
        L1IdFactoryPc.getInstance(); // 角色objid分配管理器

        L1World.getInstance(); // 游戏世界

        sb = new StringBuilder();
        sb.append("--------------------------------------------\r\n");
        Util.message(Util.SYSTEM_MESSAGE, sb.toString());

        initCore(); // 初始化核心
    }

    /**
     * 初始化图形界面.
     */
    private void initUI() {
        L1Font.init(); // 初始化自定义字体
        L1LoadImage.getInstance().load(); // 加载所有图片(默认路径./image)
        L1Window.getInstance(); // 增加主窗体
    }

    /**
     * 初始化服务器核心相关.
     */
    private void initCore() {
        L1GameServer.getInstance().init(); // 开始监听客户端连线
    }
}
